package com.study.spring.retry.retryByCustom;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @date 2021年11月16日 22:42
 * @description
 */
@RestController
public class CustomController {

    public static int count = 0;

    @Retry(delay = 2000,maxAttempts = 3,value = ArithmeticException.class,strategy = FastRetryStrategy.class,listener = DefaultRetryListener.class)
    @GetMapping(value = "/do-test")
    public String doTest(int code) {
        count++;
        System.out.println("code is :" + code + " result is :" + count % 3 + " count is :" + count);
        if (code == 1) {
            System.out.println("--this is a test");
        } else {
            if (count % 5 != 0) {
                System.out.println(4 / 0);
            }
        }
        return "success";
    }
}
